#pragma once

#define DIRECTINPUT_VERSION 0x0800
//Macros
#define KEYDOWN(name, key) (name[key] & 0x80)
#define BUTTONDOWN(name, key) (name.rgbButtons[key] & 0x80)
#define DIRECTINPUT_VERSION 0x0800

#include <dinput.h>
#pragma comment(lib, "dinput8.lib")
#pragma comment(lib, "dxguid.lib")

#include "Pen.h"
#include "Character.h"

//Deals with all mouse and keyboard input for the game
// For simplicity, it deals directly with certain objects.
class Input
{
private:
	Input();								// as this is a singleton, the ctor is private

	IDirectInput8*			m_pDIObject;		// direct input device
	LPDIRECTINPUTDEVICE8	m_pDIKeyboard;		// device managing keyboard input
	LPDIRECTINPUTDEVICE8	m_pDIMouse;			// device managing mouse input
	char					m_kbBuffer[256];	// captures keyboard input
	bool					m_kbWasHit[256];	// records keyboard input
	DIMOUSESTATE			m_mouseState;		// captures mouse input
	bool					m_bMouseButtonDown[4];

public:
	~Input();
	inline static Input* Engine()			// the instance of the singleton DirectInput
	{
		static Input input;
		return &input;
	}

	

	bool			Init(HWND hWnd, HINSTANCE hInst);
	void			PollDevices();
	int				CharacterPoll(Character* C,DrawList* drawables,double Speed);
	int				AIPoll(DrawList* drawables, double Speed);
	int				MenuPoll(DrawList* ObjectsSprite);
	bool			MoviePoll();
	float			mouseDX();
	float			mouseDY();
	float			mouseDZ();
	void			CleanUp();
};